package com.gateway.enter.controller;
import com.gateway.enter.entity.Student;
import com.gateway.enter.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author KLC0422
 * @create 2021-12-26- 10:28
 */
@Controller
public class UploadController {

    @Autowired
    StudentService studentService;

    @PostMapping("/upload")
    public String uploadHead(Student student, Map<String,Object> map, HttpServletRequest request){
        Student student1 =(Student) request.getSession().getAttribute("student");
        if(student1 == null){
            map.put("msg","您还未登录");
            return "site/error";
        }
        if(student1.getActive() == 0){
            map.put("msg","您还未激活，请联系管理员");
            return "site/error";
        }
        student.setEmailAddress(student1.getEmailAddress());
        studentService.updateStudentByAddress(student);
        map.put("msg","上传成功");
        return "site/home";
    }
}
